package bpm.dao.impl.user.unite;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import bpm.dao.user.unite.UniteDao;
import bpm.domain.user.unite.UniteParam;
/**
 * 
 * @author ZhaoWangLong Nov 1, 2011
 *
 */
@Repository("uniteDao")
public class UniteDaoImpl implements UniteDao {
	@Resource private JdbcTemplate jdbcTemplate;
	private final Logger logger =Logger.getLogger(UniteDaoImpl.class);
	public void addUnite(UniteParam unite) {
		String sql="insert into  BPM_UM_UNITE (DOMAINID, SYNCKEY, ENDSYNCKEY, ISALL, APPID, APPKEY, "+
		"CREATE_DATE, UPDATE_DATE, CONTENT) values (?,?,?,?,?,?,?,?,?)";
		java.sql.Date create=null;
		java.sql.Date update=null;
		if(unite.getCreateDate()!=null)
				create=new java.sql.Date(unite.getCreateDate().getTime());
		if(unite.getUpdateDate()!=null)
				update=new java.sql.Date(unite.getUpdateDate().getTime());
		logger.debug(unite.getDomainId()+","+unite.getSyncKey()+","+unite.getEndSyncKey()+","+
				unite.getIsAll()+","+unite.getAppId()+","+unite.getAppKey()+","+
				create+","+update+","+unite.getContent());
		this.jdbcTemplate.update(sql, new Object[]{
				unite.getDomainId(),unite.getSyncKey(),unite.getEndSyncKey(),
				unite.getIsAll(),unite.getAppId(),unite.getAppKey(),
				create,update,unite.getContent()
		});
	}

}
